package dailearn.eureka.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 *
 * @author daify
 * @date 2019-07-04 11:24
 **/
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    /**
     * 新版的security默认启用了csrf检验，
     * 如果不关闭该检验，eureka client端向eureka server注册时，
     * 会报如下异常：com.netflix.discovery.shared.transport.TransportException: 
     * Cannot execute request on any known server，
     * @param http
     * @throws Exception
     */
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic();
    }
    
}
